package com.hjh.demo;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class Demo1 {
    public static void main(String[] args) {
        int count = 1000000;
        Map<String,Integer> countMap = new HashMap<>();

        for (int i = 0; i < count; i++) {
            String str = "key"+i;
            String server = ConsistentHashingWithVirtualNode.getServer(str);
            Integer serviceIndex = ConsistentHashingWithVirtualNode.serverMap.get(server);

            String key = String.valueOf(serviceIndex);
            Integer serviceCount = countMap.get(key);
            if(serviceCount == null){
                serviceCount = 1;
            }else{
                serviceCount +=1;
            }
            countMap.put(key,serviceCount);
        }

        countMap.forEach((key,value)->{
            System.out.println(key+"<<<<<<================>>>"+value);
        });
        Collection<Integer> values = countMap.values();
        Integer[] integers = new Integer[values.size()];
        values.toArray(integers);
        Biaozhun.check(integers);
    }

}
